javascript sort array of objects by number

86

sort array of objects javascript -

list.sort((a, b) => (a.color > b.color) ? 1 : -1)

sort arrays according to first array js -

itemsArray.sort(function(a, b){  
  return sortingArr.indexOf(a) - sortingArr.indexOf(b);
});

Comments

Submit
0 Comments